package com.bwie.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.common.domain.TUser;
import com.bwie.common.domain.dto.UserInfoReq;
import com.bwie.system.service.TUserService;
import com.bwie.system.mapper.TUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author zt181
* @description 针对表【t_user】的数据库操作Service实现
* @createDate 2025-07-15 09:45:31
*/
@Service
public class TUserServiceImpl extends ServiceImpl<TUserMapper, TUser>
    implements TUserService{

    @Autowired
    private TUserMapper userMapper;

    @Override
    public TUser getUserInfo(UserInfoReq req) {
        LambdaQueryWrapper<TUser> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TUser::getEmail, req.getEmail())
                .eq(TUser::getMobile, req.getMobile())
                .last("limit 1");
        return userMapper.selectOne(wrapper);
    }

    @Override
    public boolean forgetPassword(TUser user) {
        TUser userInfo = userMapper.selectOne(new LambdaQueryWrapper<TUser>().eq(TUser::getMobile, user.getMobile()));
        userInfo.setPassword(user.getPassword());
        // 根据用户id修改用户密码
        return userMapper.updateById(userInfo) > 0;
    }
}




